package tools;

import java.util.Calendar;
import java.util.Date;

public class TimeUtil {

    //判断当前时间是否位于某时间段内，不包括相等
    public static boolean isEffectiveTime(Date currentTime, Date startTime, Date dueTime) {

        Calendar current = Calendar.getInstance();
        current.setTime(currentTime);

        Calendar start = Calendar.getInstance();
        start.setTime(startTime);

        Calendar due = Calendar.getInstance();
        due.setTime(dueTime);


        return current.after(start) && current.before(due);
    }

    //判断当前时间是否位于规定时间之后，不包括相等
    public static boolean isAfterDueTime(Date currentTime, Date dueTime) {

        Calendar current = Calendar.getInstance();
        current.setTime(currentTime);

        Calendar due = Calendar.getInstance();
        due.setTime(dueTime);

        return current.after(due);
    }

    //判断当前时间是否位于规定时间之前，不包括相等
    public static boolean isBeforeStartTime(Date currentTime, Date startTime) {

        Calendar current = Calendar.getInstance();
        current.setTime(currentTime);

        Calendar start = Calendar.getInstance();
        start.setTime(startTime);

        return current.before(start);
    }
}
